<%@ include file="/common/taglibs.jsp"%>

<head>
    <title><fmt:message key="searchPerson.title"/></title>
    <meta name="heading" content="<fmt:message key='searchPerson.searchPerson'/>"/>
</head>

<form:form commandName="basicInfoForm" method="post" action="search" id="basicInfoForm" onsubmit="return validateWork(this)">
<form:errors path="*" cssClass="error" element="div"/>
<form:hidden path="basicInfo.id"/>
<ul>
    <li>
        <appfuse:label styleClass="desc" key="searchPerson.firstName"/>
        <form:input path="basicInfo.firstName" id="basicInfo.firstName" cssClass="text medium" cssErrorClass="text medium error" maxlength="50"/>
    </li>
    <li>
        <appfuse:label styleClass="desc" key="searchPerson.lastName"/>
        <form:input path="basicInfo.lastName" id="basicInfo.lastName" cssClass="text medium" cssErrorClass="text medium error" maxlength="50"/>
    </li>
    <li>
        <appfuse:label styleClass="desc" key="searchPerson.socScrNo"/>
        <form:input path="basicInfo.socScrNo" id="basicInfo.socScrNo" cssClass="text medium" cssErrorClass="text medium error" maxlength="50"/>
    </li>
     <li>
            <appfuse:label styleClass="desc" key="basicInfo.municipality"/>
            <form:select path="basicInfo.municipality.id" id="municipalitySelect">
                <form:option id="1" value="">
                    Odberete opstina
                </form:option>
                <c:forEach items="${basicInfoForm.municipalities}" var="municipality">

                    <c:if test="${municipality == basicInfoForm.basicInfo.municipality}">
                        <form:option value="${municipality.id}" id="${basicInfoForm.basicInfo.municipality.id}" selected="true" >
                            ${manicipality.name}
                        </form:option>
                    </c:if>
                    <c:if test="${municipality != basicInfoForm.basicInfo.country}">
                        <form:option value="${municipality.id}" id="${basicInfoForm.basicInfo.municipality.id}" >
                            ${municipality.name}
                        </form:option>
                    </c:if>
                </c:forEach>
            </form:select>
        </li>
        <li>
            <appfuse:label styleClass="desc" key="basicInfo.nationality"/>
            <form:select path="basicInfo.nationality.id" id="nationalitySelect">
                <form:option id="1" value="">
                    Odberete Nacionalnost
                </form:option>
                <c:forEach items="${basicInfoForm.nationalities}" var="nationality">

                    <c:if test="${nationality == basicInfoForm.basicInfo.nationality}">
                        <form:option value="${nationality.id}" id="${basicInfoForm.basicInfo.nationality.id}" selected="true" >
                            ${nationality.nationalityName}
                        </form:option>
                    </c:if>
                    <c:if test="${nationality != basicInfoForm.basicInfo.nationality}">
                        <form:option value="${nationality.id}" id="${basicInfoForm.basicInfo.nationality.id}" >
                            ${nationality.nationalityName}
                        </form:option>
                    </c:if>
                </c:forEach>
            </form:select>
        </li>
        <li>
            <appfuse:label styleClass="desc" key="basicInfo.eduLvl"/>
            <form:select path="basicInfo.eduLvl.id" id="eduLvlSelect">
                <form:option id="1" value="">
                    Odberete Nivo na Obrazovanie
                </form:option>
                <c:forEach items="${basicInfoForm.educationLevels}" var="eduLvl">

                    <c:if test="${eduLvl == basicInfoForm.basicInfo.eduLvl}">
                        <form:option value="${eduLvl.id}" id="${basicInfoForm.basicInfo.eduLvl.id}" selected="true" >
                            ${eduLvl.eduLvlName}
                        </form:option>
                    </c:if>
                    <c:if test="${eduLvl != basicInfoForm.basicInfo.eduLvl}">
                        <form:option value="${eduLvl.id}" id="${basicInfoForm.basicInfo.eduLvl.id}" >
                            ${eduLvl.eduLvlName}
                        </form:option>
                    </c:if>
                </c:forEach>
            </form:select>
        </li>
        <li>
            <appfuse:label styleClass="desc" key="basicInfo.gender"/>
            <form:select path="basicInfo.gender" id="genderSelect">
                <form:option id="1" value="">
                    Odberete Pol
                </form:option>
                <c:if test="${'Male' == basicInfoForm.basicInfo.gender}"> <form:option id="2" value="Male" selected="true" /> </c:if>  <c:if test="${'Male' != basicInfoForm.basicInfo.gender}"> <form:option id="2" value="Male" /> </c:if>
                <c:if test="${'Female' == basicInfoForm.basicInfo.gender}"> <form:option id="3" value="Female" selected="true" /> </c:if>  <c:if test="${'Female' != basicInfoForm.basicInfo.gender}"> <form:option id="3" value="Female" /> </c:if>
            </form:select>
        </li>

    <li class="buttonBar bottom">
        <input type="submit" class="button" name="search" value="<fmt:message key="button.search"/>"/>
        <input type="submit" class="button" name="cancel" value="<fmt:message key="button.cancel"/>" onclick="bCancel=true"/>
    </li>
</ul>
</form:form>

<display:table name="searchList" class="table" requestURI="" id="searchList" export="false" pagesize="25">
    <display:column property="firstName" titleKey="employment.firstName" sortable="true" href="workpositionformprijava?" media="html"
        paramId="bi" paramProperty="id" />
    <display:column property="lastName" sortable="true" titleKey="basicInfo.lastName"/>
    <display:column property="socScrNo" sortable="true" titleKey="basicInfo.socScrNo"/>
    <display:column property="nationality.nationalityName" sortable="true" titleKey="basicInfo.socScrNo"/>
    <display:column property="municipality.name" sortable="true" titleKey="basicInfo.socScrNo"/>
    <display:column property="gender" sortable="true" titleKey="basicInfo.socScrNo"/>
    <display:column property="eduLvl.eduLvlName" sortable="true" titleKey="basicInfo.socScrNo"/>
</display:table>

<v:javascript formName="basicInfoForm" cdata="false" dynamicJavascript="true" staticJavascript="false"/>
<script type="text/javascript" src="<c:url value='/scripts/validator.jsp'/>"></script>

<script type="text/javascript">
    Form.focusFirstElement($('basicInfoForm'));
</script>

<script type="text/javascript">
    highlightTableRows("searchList");
</script> 